package com.qfedu.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

/**
 * @ClassName SpringMvcConfig
 * @Author ykx
 * @Date 2024/5/20 16:59
 * @Version 1.0
 */
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"com.qfedu.controller"})
public class SpringMvcConfig extends WebMvcConfigurationSupport {

    @Bean
    public ViewResolver viewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setPrefix("/html");
        viewResolver.setSuffix(".html");

        // 配置jsp页面可以通过${}访问beans
        viewResolver.setExposeContextBeansAsAttributes(true);
        return viewResolver;
    }

}
